<template>
	<div>
		<div v-show="true" class="" style="width: 100%;height: 100%; position:fixed;left:0;top:0;background-color: rgba(0,0,0,0.1);display: flex;justify-content: center;align-items: center;z-index: 350;">
<!--		<mu-circular-progress :size="48" color="green"/>-->
		<mu-linear-progress />
		</div>
	</div>
</template>

<script>
export default{
	data(){
		return{
			
		}
	},
	computed:{
		url(){
			return `${this.$store.state.schoolUrl}/Login/tokenLogin`
		},
		academicDateUrl(){
			return `${this.$store.state.schoolUrl}/courseDate/getDayInfo/${new Date().format("yyyy-MM-dd")}`
		},
		loadCoureInfoUrl(){
			return `${this.$store.state.schoolUrl}/course/${new Date().format("yyyy-MM-dd")}/${this.$store.state.userInfo.studentClassId}/ClassDayCourse`
		}
	},
	 mounted(){
	 	this.init()
	 	this.getAcademicDate()
		this.login()	
  		},
	methods:{
		init(){
			localStorage.token=this.$route.query.token
			this.$store.commit('getInfo',
	 		{token:this.$route.query.token,
	 		schoolUrl:this.$route.query.schoolUrl,
	 		loginUrl: this.$route.query.loginUrl,
	 		loginType:'wechatLogin'})
	 		console.info(this.$store.state)	
		},
		login(){ 	
			//获取版本号注释登录
			let that=this
			console.info(that.url)
	      	that.axios.post(that.url,{
	      			'token':that.$store.state.token
	      		}).then(function(response){
	      			console.log('成功')
					if(response.data.userRole=='studentInfo'){
	      			that.$store.commit('getUserInfo',
	      			{'userInfo':response.data.studentInfo,
	      			 'userRole':response.data.userRole,
	      			 'MenuList':response.data.MenuList
	      			})
	      		}else{
	      			that.$store.commit('getUserInfo',
	      			{'userInfo':response.data.teacherInfo,
	      			 'userRole':response.data.userRole,
	      			 'MenuList':response.data.MenuList
	      			})
	      		}
	      			that.loadCoureInfo()

	      		}).catch(function(error){
	      			 console.log(error)
	      			 console.log('失败')
	      			// window.location.href=that.$store.state.loginUrl
	      		})
			
			
		},
		//获取公共学年学期 和教学周
  		getAcademicDate(data){
  			let that=this
  			that.axios.get(that.academicDateUrl).then(function(response){
					 console.log(response.data)
					 let myDate=new Date()
					 let week=['日','一','二','三','四','五','六']
					 let month=(myDate.getMonth()+1)+'-'+myDate.getDate()
					 let teachDateInfo= {
					 	'academic':response.data.courseAcademicYear,
					 	'semester':response.data.courseAcademicTerm,
					 	'teachWeek':response.data.courseWhichWeek,
					 	'weekDay':`周${week[myDate.getDay()]}`,
					 	'month':new Date().format("yyyy-MM-dd")
					 }
				that.$store.dispatch('getTeachDateInfo',teachDateInfo)
				console.log(that.$store.state.teachDateInfo)
					 
  			})
  		},
  		//获取今天的课程
  		loadCoureInfo(){
  			let that = this
	      	that.axios.get(that.loadCoureInfoUrl).then(function (response) {
	      		that.$store.commit('getCoureInfo',response.data)
	      		console.log(that.$store.state.todayCourse)
	      		setTimeout(function(){
	           			that.$router.push(that.$store.state.userRole)
	           		},1480)
	      	}).catch(function (error) {
	        	console.log(error);
	      	});
  		},
  		
		
	}
}
</script>

<style>
</style>